<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	
%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- Meta, title, CSS, favicons, etc. -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<title>随便打TCS系统</title>
<!-- Bootstrap -->
<link href="<%=basePath%>vendors/bootstrap/dist/css/bootstrap.min.css"
	rel="stylesheet">
<!-- Font Awesome -->
<link
	href="//netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"
	rel="stylesheet">
<!-- Select2 -->
<link href="<%=basePath%>vendors/select2/dist/css/select2.min.css"
	rel="stylesheet">
<!-- NProgress -->
<link href="<%=basePath%>vendors/nprogress/nprogress.css"
	rel="stylesheet">
<!-- iCheck -->
<link href="<%=basePath%>vendors/iCheck/skins/flat/green.css"
	rel="stylesheet">

<!-- bootstrap-progressbar -->
<link
	href="<%=basePath%>vendors/bootstrap-progressbar/css/bootstrap-progressbar-3.3.4.min.css"
	rel="stylesheet">
<!-- JQVMap -->
<link href="<%=basePath%>vendors/jqvmap/dist/jqvmap.min.css"
	rel="stylesheet" />
<!-- bootstrap-daterangepicker -->
<link
	href="<%=basePath%>vendors/bootstrap-daterangepicker/daterangepicker.css"
	rel="stylesheet">

<!-- Custom Theme Style -->
<link href="<%=basePath%>build/css/custom.min.css" rel="stylesheet">
<style>
	.x_panel .x_content{
		flex:1;
	}
	.x_content label{text-align: left !important;}
	.x_panel .reward{flex:1}
</style>
</head>

<body class="nav-md">
	<div class="container body">
		<div class="main_container">
			<div class="col-md-3 left_col">
				<div class="left_col scroll-view">
					<div class="clearfix"></div>
					<br />
				</div>
			</div>


			<!-- page content -->
			<div class="right_col" role="main">
				<div class="">
					<div class="page-title">
                        <div class="row tile_count">
                            <div class="col-md-2 col-sm-4 col-xs-6 tile_stats_count">
                                <span class="count_top"><i class="fa fa-user"></i>总金额</span>
                                <div id="countall" class="count">${igrewardAll + withdrawalsAll}</div>
                            </div>
                            <div class="col-md-2 col-sm-4 col-xs-6 tile_stats_count">
                                <span class="count_top"><i class="fa fa-user"></i>账号金额</span>
                                <div id="counttotle" class="count">${igrewardAll}</div>
                            </div>
                            <div class="col-md-2 col-sm-4 col-xs-6 tile_stats_count">
                                <span class="count_top"><i class="fa fa-user"></i>提现金额</span>
                                <div id="countnew" class="count">${withdrawalsAll}</div>
                            </div>
						<div class="title_left"></div>
                        </div>
					</div>
					<div class="clearfix"></div>

					<div class="row">
						<div class="col-md-12 col-sm-12 col-xs-12">
							<div class="x_panel">
								<div class="x_title">
									<div class="clearfix"></div>
								</div>
								<div style="display:flex;">
									<div class="x_content">
										<a href="javascript:" type="submit" class="btn btn-success"
										   onclick="updateCard('${id}','${mobile}')">升级年费</a>
										<a href="javascript:" type="submit" class="btn btn-success"
										   onclick="selectSTRewards('${id}')">进出账明细</a>

										<form name="myForm" class="form-horizontal form-label-left" novalidate
											  method= "post" enctype ="multipart/form-data" id="formUpload" >
											<%--<span class="section"></span>--%>

											<div class="item form-group" style="display:none">
												<label class="control-label col-md-3 col-sm-3 col-xs-12"
													   for="name">id<span class="required"></span>
												</label>
												<div class="col-md-6 col-sm-6 col-xs-12">
													<input id="id" name="id" class="form-control col-md-7 col-xs-12"
														   type="text" value="${id}">
												</div>
											</div>
											<div class="item form-group">
												<label class="control-label col-md-3 col-sm-3 col-xs-12"
													   for="name">在线充值积分 </label>
												<div class="col-md-6 col-sm-6 col-xs-12">
													<input class="form-control col-md-7 col-xs-12" name="name"
														   placeholder="" type="text" value="" id="igreward">
												</div>
											</div>
											<c:if test="${adminUserId == 'd093179851af43dfbb1bc6639334b109'}">
												<div class="item form-group">
													<label class="control-label col-md-3 col-sm-3 col-xs-12"
														   for="name" >一级(一店)等级<span
															class="required">*</span>
													</label>
													<div class="col-md-6 col-sm-6 col-xs-12">
														<select class="form-control" id="cbonus1level">
															<option value="0" <c:if test="${cbonus1level == 0}">selected</c:if>>无选择等级</option>
															<option value="1" <c:if test="${cbonus1level == 1}">selected</c:if>>T1</option>
															<option value="2" <c:if test="${cbonus1level == 2}">selected</c:if>>T2</option>
															<option value="3" <c:if test="${cbonus1level == 3}">selected</c:if>>T3</option>
															<option value="4" <c:if test="${cbonus1level == 4}">selected</c:if>>T4</option>
															<option value="5" <c:if test="${cbonus1level == 5}">selected</c:if>>T5</option>
															<option value="6" <c:if test="${cbonus1level == 6}">selected</c:if>>T6</option>
															<option value="7" <c:if test="${cbonus1level == 7}">selected</c:if>>T7</option>
															<option value="8" <c:if test="${cbonus1level == 8}">selected</c:if>>T8</option>
															<option value="9" <c:if test="${cbonus1level == 9}">selected</c:if>>T9</option>
														</select>
													</div>
												</div>
												<div class="item form-group">
													<label class="control-label col-md-3 col-sm-3 col-xs-12"
														   for="name">一级(一店)业绩 </label>
													<div class="col-md-6 col-sm-6 col-xs-12">
														<input class="form-control col-md-7 col-xs-12" name="name"
															   placeholder="" type="text" value="${achievement1}" id="achievement1">
													</div>
												</div>
												<div class="item form-group">
													<label class="control-label col-md-3 col-sm-3 col-xs-12"
														   for="name" >二级(二店)等级<span
															class="required">*</span>
													</label>
													<div class="col-md-6 col-sm-6 col-xs-12">
														<select class="form-control" id="cbonus2level">
															<option value="0" <c:if test="${cbonus2level == 0}">selected</c:if>>无选择等级</option>
															<option value="4" <c:if test="${cbonus2level == 4}">selected</c:if>>T4</option>
															<option value="5" <c:if test="${cbonus2level == 5}">selected</c:if>>T5</option>
															<option value="6" <c:if test="${cbonus2level == 6}">selected</c:if>>T6</option>
															<option value="7" <c:if test="${cbonus2level == 7}">selected</c:if>>T7</option>
															<option value="8" <c:if test="${cbonus2level == 8}">selected</c:if>>T8</option>
															<option value="9" <c:if test="${cbonus2level == 9}">selected</c:if>>T9</option>
														</select>
													</div>
												</div>
												<div class="item form-group">
													<label class="control-label col-md-3 col-sm-3 col-xs-12"
														   for="name">二级(二店)业绩 </label>
													<div class="col-md-6 col-sm-6 col-xs-12">
														<input class="form-control col-md-7 col-xs-12" name="name"
															   placeholder="" type="text" value="${achievement2}" id="achievement2">
													</div>
												</div>
												<div class="item form-group">
													<label class="control-label col-md-3 col-sm-3 col-xs-12"
														   for="name" >三级(三店)等级<span
															class="required">*</span>
													</label>
													<div class="col-md-6 col-sm-6 col-xs-12">
														<select class="form-control" id="cbonus3level">
															<option value="0" <c:if test="${cbonus3level == 0}">selected</c:if>>无选择等级</option>
															<option value="7" <c:if test="${cbonus3level == 7}">selected</c:if>>T7</option>
															<option value="8" <c:if test="${cbonus3level == 8}">selected</c:if>>T8</option>
															<option value="9" <c:if test="${cbonus3level == 9}">selected</c:if>>T9</option>
														</select>
													</div>
												</div>
												<div class="item form-group">
													<label class="control-label col-md-3 col-sm-3 col-xs-12"
														   for="name">三级(三店)业绩 </label>
													<div class="col-md-6 col-sm-6 col-xs-12">
														<input class="form-control col-md-7 col-xs-12" name="name"
															   placeholder="" type="text" value="${achievement3}" id="achievement3">
													</div>
												</div>
												<div class="item form-group">
													<label class="control-label col-md-3 col-sm-3 col-xs-12"
														   for="name" >是否开启总特权<span
															class="required">*</span>
													</label>
													<div class="col-md-6 col-sm-6 col-xs-12">
														<select class="form-control" id="isallprivilege">
															<c:if test="${isallprivilege == 1 }">
																<option value="1" selected="selected">开启</option>
																<option value="0">关闭</option>
															</c:if>
															<c:if test="${isallprivilege == 0 }">
																<option value="1">开启</option>
																<option value="0" selected="selected">关闭</option>
															</c:if>
														</select>
													</div>
												</div>
												<div class="item form-group">
													<label class="control-label col-md-3 col-sm-3 col-xs-12"
														   for="name">总特权比例 </label>
													<div class="col-md-6 col-sm-6 col-xs-12">
														<input class="form-control col-md-7 col-xs-12" name="name"
															   placeholder="" type="text" value="${allteamreratio}" id="allteamreratio">
													</div>
												</div>
												<div class="item form-group">
													<label class="control-label col-md-3 col-sm-3 col-xs-12"
														   for="name" >是否开启副特权<span
															class="required">*</span>
													</label>
													<div class="col-md-6 col-sm-6 col-xs-12">
														<select class="form-control" id="isprivilege">
															<c:if test="${isprivilege == 1 }">
																<option value="1" selected="selected">开启</option>
																<option value="0">关闭</option>
															</c:if>
															<c:if test="${isprivilege == 0 }">
																<option value="1">开启</option>
																<option value="0" selected="selected">关闭</option>
															</c:if>
														</select>
													</div>
												</div>
												<div class="item form-group">
													<label class="control-label col-md-3 col-sm-3 col-xs-12"
														   for="name">副特权比例 </label>
													<div class="col-md-6 col-sm-6 col-xs-12">
														<input class="form-control col-md-7 col-xs-12" name="name"
															   placeholder="" type="text" value="${teamreratio}" id="teamreratio">
													</div>
												</div>
												<div class="item form-group">
													<label class="control-label col-md-3 col-sm-3 col-xs-12"
														   for="name" >是否允许提现<span
															class="required">*</span>
													</label>
													<div class="col-md-6 col-sm-6 col-xs-12">
														<select class="form-control" id="iswithdraw">
															<c:if test="${iswithdraw == 1 }">
																<option value="1" selected="selected">允许</option>
																<option value="0">不允许</option>
															</c:if>
															<c:if test="${iswithdraw == 0 }">
																<option value="1">允许</option>
																<option value="0" selected="selected">不允许</option>
															</c:if>
														</select>
													</div>
												</div>
												<div class="item form-group">
													<label class="control-label col-md-3 col-sm-3 col-xs-12"
														   for="name" >是否允许全球分红<span
															class="required">*</span>
													</label>
													<div class="col-md-6 col-sm-6 col-xs-12">
														<select class="form-control" id="isbonus">
															<c:if test="${isbonus == 1 }">
																<option value="1" selected="selected">允许</option>
																<option value="0">不允许</option>
															</c:if>
															<c:if test="${isbonus == 0 }">
																<option value="1">允许</option>
																<option value="0" selected="selected">不允许</option>
															</c:if>
														</select>
													</div>
												</div>
												<div class="item form-group">
													<label class="control-label col-md-3 col-sm-3 col-xs-12"
														   for="name" >是否允许特权分红<span
															class="required">*</span>
													</label>
													<div class="col-md-6 col-sm-6 col-xs-12">
														<select class="form-control" id="isperformance">
															<c:if test="${isperformance == 1 }">
																<option value="1" selected="selected">允许</option>
																<option value="0">不允许</option>
															</c:if>
															<c:if test="${isperformance == 0 }">
																<option value="1">允许</option>
																<option value="0" selected="selected">不允许</option>
															</c:if>
														</select>
													</div>
												</div>
											</c:if>
										</form>
									</div>
									<div class="reward">
										<table id="datatable" class="table table-striped table-bordered">
											<thead>
											<tr>
												<th>类型</th>
												<th>时间</th>
												<th>状态</th>
												<th>金额</th>
												<th>等级</th>
											</tr>
											</thead>
											<tbody>
											<c:forEach items="${list}" var="s" varStatus="z">

												<tr>
													<td><c:if test="${s.type == 2}">红包奖励</c:if>
														<c:if test="${s.type == 3}">全球分红</c:if>
														<c:if test="${s.type == 4}">手动添加</c:if></td>
													<td><fmt:formatDate value="${s.createtime}" type="date"
																		pattern="yyyy-MM-dd" /></td>
													<td>+</td>
													<td>${s.integral}</td>
													<td><c:if test="${s.type == 2}">${s.level}级充值分红</c:if></td>
												</tr>
											</c:forEach>
											</tbody>
										</table>
									</div>
								</div>
								<div class="ln_solid"></div>
								<div class="form-group">
									<div class="col-md-6 col-md-offset-3">
										<a type="submit" class="btn btn-primary"
										   href="javascript:void(0)"
										   onclick="history.back(-1);">取消</a>
										<input id="revise" type="button" class="btn btn-success"
											   href="javascript:void(0)"  onclick="ajaxPost()" value="修改" >
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
			<!-- /page content -->
			<!-- 上传图片并修改 -->
			<script src="<%=basePath%>vendors/jquery/dist/jquery.min.js"></script>
			<script type="text/javascript" >
			
            </script>
            
			<script type="text/javascript">
                function selectZXRewards(userid) {
                    location.href = "zxRewards?userid=" + userid;
                }
                function selectSTRewards(userid) {
                    location.href = "stAddRewards?userid=" + userid + "&type=1";
                }

				//获取select中的选项以及value
				// ajax 对象
				function ajaxObject() {
					var xmlHttp;
					try {
						// Firefox, Opera 8.0+, Safari
						xmlHttp = new XMLHttpRequest();
					} catch (e) {
						// Internet Explorer
						try {
							xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
						} catch (e) {
							try {
								xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
							} catch (e) {
								alert("您的浏览器不支持AJAX！");
								return false;
							}
						}
					}
					return xmlHttp;
				}
			
				// ajax post请求：
				function ajaxPost() {
					var id = $("#id").val();
					var achievement1 = $("#achievement1").val();
					if (achievement1 == undefined) {
						achievement1 = "";
					}
					var achievement2 = $("#achievement2").val();
					if (achievement2 == undefined) {
						achievement2 = "";
					}
					var achievement3 = $("#achievement3").val();
					if (achievement3 == undefined) {
						achievement3 = "";
					}
					var igreward = $("#igreward").val();
					var isallprivilege = $("#isallprivilege").find("option:selected").val();
					if (isallprivilege == undefined) {
						isallprivilege = "";
					}
					var allteamreratio = $("#allteamreratio").val();
					if (allteamreratio == undefined) {
						allteamreratio = "";
					}
					var isprivilege = $("#isprivilege").find("option:selected").val();
					if (isprivilege == undefined) {
						isprivilege = "";
					}
					var teamreratio = $("#teamreratio").val();
					if (teamreratio == undefined) {
						teamreratio = "";
					}
					var iswithdraw = $("#iswithdraw").find("option:selected").val();
					if (iswithdraw == undefined) {
						iswithdraw = "";
					}
					var isbonus = $("#isbonus").find("option:selected").val();
					if (isbonus == undefined) {
						isbonus = "";
					}
					var isperformance = $("#isperformance").find("option:selected").val();
					if (isperformance == undefined) {
						isperformance = "";
					}
					var cbonus1level = $("#cbonus1level").find("option:selected").val();
					if (cbonus1level == undefined) {
						cbonus1level = "";
					}
					var cbonus2level = $("#cbonus2level").find("option:selected").val();
					if (cbonus2level == undefined) {
						cbonus2level = "";
					}
					var cbonus3level = $("#cbonus3level").find("option:selected").val();
					if (cbonus3level == undefined) {
						cbonus3level = "";
					}
					var ajax = ajaxObject();
					ajax.open("post", "updateSubscribers?id=" + id +
							"&achievement1=" + achievement1 +
							"&achievement2=" + achievement2 +
							"&achievement3=" + achievement3 +
							"&iswithdraw=" + iswithdraw +
							"&isbonus=" + isbonus +
							"&isperformance=" + isperformance +
							"&isallprivilege=" + isallprivilege +
							"&allteamreratio=" + allteamreratio +
							"&isprivilege=" + isprivilege +
							"&teamreratio=" + teamreratio +
							"&cbonus1level=" + cbonus1level +
							"&cbonus2level=" + cbonus2level +
							"&cbonus3level=" + cbonus3level +
							"&igreward=" + igreward, true);
					ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
					ajax.onreadystatechange = function() {
						if (ajax.readyState == 4) {
							if (ajax.status == 200) {
								var result = ajax.responseText;
								if (result == "success") {
									//请求成功
									alert("修改成功");
									location.href = "content_yonghuguanli";
								} else {
									//请求成功
									alert(result);
									location.href = "content_yonghuguanli";
								}
							} else {
								//请求失败
								alert("请求终止，请检查操作或联系客服咨询" + ajax.status);
							}
						} else {
						}
					};
					ajax.send();
				}

                function updateCard(id,mobile) {
                    var d = new Date();
                    d.setFullYear(d.getFullYear() + 1);  //加一年
                    var endtime = d.getFullYear() + "-" + d.getMonth() + "-" +d.getDate();
                    var ajax = ajaxObject();
                    ajax.open("post", "updateSubscribers?id=" + id +
                        "&money=" + 5000 +
                        "&endtime=" + endtime +
                        "&mobile=" + mobile +
                        "&isyearcard=" + 1, false);
                    ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
                    ajax.onreadystatechange = function() {
                        if (ajax.readyState == 4) {
                            if (ajax.status == 200) {
                                var result = ajax.responseText;
                                if (result == "success") {
                                    //请求成功
                                    if(mobile != null ){
                                        alert(mobile+"账号升级为年卡用户");
                                        selectOEM(${curPage});
                                    }
                                } else {
                                    //请求成功
                                    alert(result);
                                }
                            } else {
                                //请求失败
                                selectOEM(${curPage});
                            }
                        } else {
                        }
                    };
                    ajax.send();
                }
			</script>
		</div>
	</div>

	<!-- jQuery -->
	<script src="<%=basePath%>vendors/jquery/dist/jquery.min.js"></script>
	<!-- Bootstrap -->
	<script src="<%=basePath%>vendors/bootstrap/dist/js/bootstrap.min.js"></script>
	<!-- FastClick -->
	<script src="<%=basePath%>vendors/fastclick/lib/fastclick.js"></script>
	<!-- NProgress -->
	<script src="<%=basePath%>vendors/nprogress/nprogress.js"></script>
	<!-- bootstrap-daterangepicker -->
	<script src="<%=basePath%>vendors/moment/min/moment.min.js"></script>
	<script
		src="<%=basePath%>vendors/bootstrap-daterangepicker/daterangepicker.js"></script>
	<!-- Chart.js -->
	<script src="<%=basePath%>vendors/Chart.js/dist/Chart.min.js"></script>
	<!-- validator -->
	<script src="<%=basePath%>vendors/validator/validator.js"></script>
	<!-- Custom Theme Scripts -->
	<script src="<%=basePath%>build/js/custom.min.js"></script>
	<!-- Select2 -->
	<script src="<%=basePath%>vendors/select2/dist/js/select2.full.min.js"></script>
</body>
</html>